#include<iostream>
#include<vector>
#include<stack>
#include<string>
using namespace std;

class Solution {
public:
    int evalRPN(vector<string>& tokens)
    {
        stack<int>st;

        for (auto& str : tokens)
        {
            if (str == "+" || str == "-" || str == "*" || str == "/")
            {
                int right = st.top(); st.pop();
                int left = st.top(); st.pop();
                switch(str[0])
                {
                case('+'):
                    st.push(left + right);
                    break;
                case('-'):
                    st.push(left - right);
                    break;
                case('*'):
                    st.push(left * right);
                    break;
                case('/'):
                    st.push(left / right);
                    break;

                }
            }
            else
            {
                st.push(stoi(str));
            }
        }
        return st.top();
    }
};